﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/Admin.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div class="listingActions">
        <a href="modify.aspx">Add new item</a>
    </div>
    <div id="ItemHeader" class="NavigationHeader">
        Navigationname (Actions)
    </div>
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <asp:ReorderList 
                ID="NavigationReorderList" 
                runat="server" 
                AllowReorder="True" 
                DataSourceID="SqlDataSource1" 
                PostBackOnReorder="True"
                DragHandleAlignment="right"
                DataKeyField="navigationID"
                SortOrderField="navigationPosition"
                ClientIDMode="AutoID"
                CssClass="NavigationReoderList">
                <DragHandleTemplate>
                    <div class="NavigationItemDrag"> </div>
                </DragHandleTemplate>
                <ReorderTemplate>
                    <div class="NavigationItemDragMove"> </div>
                </ReorderTemplate>
                <ItemTemplate>
                    <div class="ItemName"><%# Eval("navigationName")%></div><div>(<a href="/CMSProject/Administration/content/index.aspx?navID=<%#Eval("navigationID")%>">List content</a> - <a href="/CMSProject/Administration/content/modify.aspx?navID=<%#Eval("navigationID")%>">Add content</a> - <a href="modify.aspx?id=<%#Eval("navigationID") %>">Update</a> - <a href="delete.aspx?id=<%#Eval("navigationID") %>">Delete</a>)</div>
                </ItemTemplate>
            </asp:ReorderList>
        </ContentTemplate>    
    </asp:UpdatePanel>
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString.ProviderName %>"
        SelectCommand="SELECT [navigationID], [navigationName], [navigationPosition] FROM [Navigation] ORDER BY [navigationPosition]"
        UpdateCommand="UPDATE [Navigation] SET [navigationPosition]=@navigationPosition WHERE [navigationID]=@navigationID">
        <UpdateParameters>
            <asp:Parameter Name="navigationID" Type="Int32" />
            <asp:Parameter Name="navigationName" Type="String" />
            <asp:Parameter Name="navigationPosition" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

